package io.github.luons.mediator.dsl.view;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.luons.mediator.core.constant.Constant;
import io.github.luons.mediator.core.spi.cube.Dimension;
import io.github.luons.mediator.core.spi.cube.Measure;
import io.github.luons.mediator.dsl.view.filter.FilterGroup;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * FilterGroupsRequest
 *
 * @author : luons
 */
@Data
public class FilterGroupsRequest implements Serializable {

    /**
     * filterGroup, filter is and
     */
    private List<FilterGroup> filters;

    /**
     * filter function
     */
    public void filters(FilterGroup filters) {
        if (this.filters == null) {
            this.filters = new ArrayList<>();
        }
        this.filters.add(filters);
    }

    /**
     * pageNumber range:[1,∞)
     */
    @JsonProperty(Constant.PAGE_NUMBER)
    private Integer pageNumber;

    /**
     * pageSize，range:[1,100), default 10
     */
    @JsonProperty("pageSize")
    private Integer pageSize;

    /**
     * searchColumns(split by ,）
     */
    @JsonProperty("searchColumns")
    private String searchColumns;

    /**
     * keyword
     */
    private String keyword;

    /**
     * orderFields(split by ,）
     */
    @JsonProperty("orderFields")
    private String orderFields;

    /**
     * orderBy（DESC/ASC）default DESC
     */
    @JsonProperty("orderBy")
    private String orderBy;

    /**
     * dimensions (used by group by)
     */
    protected List<Dimension> dimensions;

    /**
     * measures (used by Calculator value)
     */
    protected List<Measure> measures;

}
